package com.stn.zjx.givingtreasure.net.impl;

import com.lzy.okgo.OkGo;
import com.lzy.okgo.callback.StringCallback;
import com.stn.zjx.givingtreasure.net.QQWeixinApi;
import com.stn.zjx.givingtreasure.net.UserApi;
import com.stn.zjx.givingtreasure.utils.ToolsUtils;

import org.json.JSONObject;

public class QQWeixinNetImpl  {
    /**
     * @apiNote 动态短信无密码登录

     * @param userNickname 昵称
     * @param userAvatar 头像
     * @param userSex 性别
     * @param id ID
     * @param loginType 登录方式
     * @param location 位置信息 json文本
     * @param tag 标签
     * @param callback 请求回调

     */
    public  static  void qqweixin_third_login(String userNickname,
                                              String userAvatar,
                                              Integer userSex,
                                              String id,
                                              Integer loginType,
                                               String location,
                                               String tag, StringCallback callback){
        String data="";
        JSONObject jsonObject=new JSONObject();
        try {
            jsonObject.put("userNickname",userNickname);
            jsonObject.put("userAvatar",userAvatar);
            jsonObject.put("userSex",userSex);
            jsonObject.put("id",id);
            jsonObject.put("loginType",loginType);
            jsonObject.put("location",location);
            data= ToolsUtils.getEncryptionParams(jsonObject.toString());
        } catch (Exception e) {
            e.printStackTrace();

            return;
        }

        OkGo.<String>post(QQWeixinApi.qqweixin_third_login)
                .tag(tag)
                .isSpliceUrl(true)
                .upJson("")
                .params("data",data)
                .execute(callback);

    }



      /**
     * @apiNote 手机号，微信，QQ绑定

     */
    public  static  void qqweixin_third_relation(String id,String userPhone,Integer type,String token,String tag, StringCallback callback){
        String data="";
        JSONObject jsonObject=new JSONObject();
        try {
            jsonObject.put("id",id);
            jsonObject.put("type",type);
            jsonObject.put("userPhone",userPhone);
            data= ToolsUtils.getEncryptionParams(jsonObject.toString());
        } catch (Exception e) {
            e.printStackTrace();

            return;
        }

        OkGo.<String>post(QQWeixinApi.qqweixin_third_relation)
                .tag(tag)
                .isSpliceUrl(true)
                .upJson("")
                 .params("token",token)
                .params("data",data)
                .execute(callback);

    }


    /**
     * @apiNote 手机号，微信，QQ解绑

     */
    public  static  void qqweixin_third_norelation(Integer type,String token,String tag, StringCallback callback){
        String data="";
        JSONObject jsonObject=new JSONObject();
        try {

            jsonObject.put("type",type);

            data= ToolsUtils.getEncryptionParams(jsonObject.toString());
        } catch (Exception e) {
            e.printStackTrace();

            return;
        }

        OkGo.<String>post(QQWeixinApi.qqweixin_third_norelation)
                .tag(tag)
                .isSpliceUrl(true)
                .upJson("")
                .params("token",token)
                .params("data",data)
                .execute(callback);

    }
}
